#include <iostream>
#include "Tcpserver.hpp"
#include "Protocol.hpp"
#include<memory>
#include "Cal.hpp"
#include "Daemon.hpp"
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        exit(USAGE_ERR);
    }
    uint16_t port = std::stoi(argv[1]);
    Daemon();
    std::unique_ptr<Cal> cal = std::make_unique<Cal>();
    //创建协议
    std::unique_ptr<Protocal> p = std::make_unique<Protocal>([&cal](Request& req)->Response{
        return cal->Exeute(req);
    });
    //服务层
    std::unique_ptr<Tcpserver> server = std::make_unique<Tcpserver>(port,[&p](std::shared_ptr<Socket> &sock, InetAddr &client){
        p->GetRequest(sock,client);
    }) ;
    server->Start();
    return 0;
}